/*
 * 文件名               :  Main.java
 * 用途                    :  客户端启动程序
 * 最后修改日期:  $LastChangedDate: 2009-10-17 03:54:49 +0000 (Sat, 17 Oct 2009) $
 * 最后修改者     :  $LastChangedBy: wendal1985@gmail.com $
 * 创建者               :  Wendal Chen <wendal1985@gmail.com>
 */
package com.wendal.java.preproxy.client;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.Socket;

import com.wendal.java.preproxy.bean.LoginMessageBean;
import com.wendal.java.preproxy.bridge.BridgeConnector;
import com.wendal.java.preproxy.bridge.ByteArrayConnectHandler;
import com.wendal.java.preproxy.bridge.ByteArrayHandler;
import com.wendal.java.preproxy.server.SocketHandlerFinder;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Throwable{
		System.out.println("欢迎使用!");
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		System.out.print("请输入服务器的ip: ");
		ClientConfig.serverIp = br.readLine();
//		System.out.print("请输入服务器的端口: ");
//		ClientConfig.serverPort = br.readLine();
		System.out.print("请输入本地的端口: ");
		ClientConfig.localPort = Integer.parseInt(br.readLine());
		Socket socket = new Socket(ClientConfig.serverIp,8600);
		ByteArrayHandler handler = new ByteArrayConnectHandler();
		SocketHandlerFinder socketHandlerFinder = new SocketHandlerFinder();
		BridgeConnector connector = new BridgeConnector(socket,handler,socketHandlerFinder);
		LoginMessageBean loginMessageBean = new LoginMessageBean();
		connector.transfer(loginMessageBean);
	}
}
